﻿using System;
using System.Collections.Generic;
using DsLib;

namespace DotNetFeatures
{
    public class FuncDelegates
    {
        public static Func<BinaryTreeNode<int>, int> doubler = x => x.Value * 2;
        public static Func<int, int> intdoubler = x => x * 2;
        public static Func<int, int> intsingler = x => x;
        public static Func<int, IEnumerable<int>> intdoublerToList = x => new List<int>(x * 2);
        public static Func<int, int, bool> intSelectorFunc = (x, y) =>
        {
            //Console.WriteLine("At " + y + " is " + x + (y < 10 || x > y ? ". Taken" :""));
            //if (y < 10)
            //    return true;

            return x > y;
        };

        public static Func<int, int, bool> intSelector1(int z)
        {
            //if (y > 0)
            //return (x,y) => intSelector(z, z);// intdoubler(y);
            return intSelector;
        }

        public static Func<BinaryTreeNode<int>, int, bool> nodeSelector = (x, y) =>
        {
            return x.Value > y;
        };

        public static Func<int, int, bool> intSelector = (x, y) =>
        {
            return x > y;
        };

        public static Func<BinaryTreeNode<int>, int, bool> NodeSelectMethod(int number)
        {
            // Either of the below options work

            //return (x, y) => intSelector(number, number);
            //return nodeSelector;
            return (node, x) => SomeMethod(node, number, true);
        }

        public static Func<int, int, bool> IntSelectMethod(int number)
        {
            // Either of the below options work

            //return (x, y) => intSelector(number, number);
            return intSelector;
            //return (node, x) => SomeMethod(new BinaryTreeNode<int>(node), number, true);
        }

        private static bool SomeMethod(int node, int someNumber, bool doSomething)
        {
            return node < someNumber;
        }
        private static bool SomeMethod(BinaryTreeNode<int> node, int someNumber, bool doSomething)
        {
            return node.Value < someNumber;
        }

    }
}
